<template>
  <!-- 历史审核记录 -->
  <div>
    <FilterTable
      ref="table"
      height="450"
      :columns="columns"
      :isSelectColumn="false"
      :fetchapi="fetchApi"
      :params="fetchParams"
      :datakey="'records'"
      :onColumnsChange="columns => this.columns = columns"
      columnsRef="projectOperating_summary_departmentReview_HistorySH_01"
    ></FilterTable>
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
import { formatdateByTime } from '@/utils/index';
import { getList } from '@/api/cms-api/projectOperating/program/oemInquire/index';
export default {
  mixins: [dictionary],
  props: {
    value: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      visibleDialog: false,
      initModal: {},
      fetchParams: { planId: this.value.row.planId }, //参数
      columns: this.creatHeader(),
      fetchApi: getList //ipa 接口
    };
  },
  mounted() {
    console.log(this.value); //获取到行id
    //请求接口进行赋值，自己写
  },
  methods: {
    //table表头和数据源
    creatHeader() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        { title: '项目审核部门', dataIndex: 'reviewDept', sorter: true, hidden: true },
        { title: '项目审核部门', dataIndex: 'deptName',  showOverflowTooltip: true,sorter: true },
        { title: '项目审核人', dataIndex: 'reviewPersionName', showOverflowTooltip: true,sorter: true },
        { title: '经销商简称', dataIndex: 'dealerShortname', showOverflowTooltip: true,sorter: true },
        {
          title: '审核状态',
          dataIndex: 'reviewStatus',
          showOverflowTooltip: true,
          sorter: true,
          render: props => {
            //编码转汉字
            return <span>{this.createDictText(props.row.reviewStatus, '2531')}</span>;
          }
        },
        {
          title: '审核时间',
          dataIndex: 'reviewDate',
          showOverflowTooltip: true,
          sorter: true,
          render: props => {
            return <span>{formatdateByTime(props.row.reviewDate)} </span>;
          }
        },
        { title: '审核意见', dataIndex: 'overruleReason',showOverflowTooltip: true, sorter: true }
      ];
    },
    //日期格式化年月日
    formatDates: function(value) {
      // 这里的 value 就是需要过滤的数据
      if (value == null || value == '') {
        return '';
      }
      var date = new Date(value);
      var year = date.getFullYear();
      var month = date.getMonth() + 1;
      var day = date.getDate();
      var hh = date.getHours();
      var mm = date.getMinutes();
      const ss = date.getSeconds();
      return year + '-' + month + '-' + day + ' ' + hh + ':' + mm + ':' + ss;
    }
  }
};
</script>
